
export class Response<T> {
    code: number;
    message: string;
    data: T

    static success(): Response<any> {
        let response = new Response<any>();
        response.code = 0;
        response.message = "操作成功";
        return response;
    }

    static successWithData<U>(data: U): Response<U>{
        let response = new Response<U>();
        response.code = 0;
        response.message = "操作成功";
        response.data = data;
        return response;
    }

    static error(): Response<any>{
        let response = new Response<any>();
        response.code = 1;
        response.message = "操作失败";
        return response;
    }

    static errorWithMessage(message:string): Response<any>{
        let response = new Response<any>();
        response.code = 1;
        response.message = message;
        return response;
    }
}